package com.facebank.usersupport.controller;

import com.facebank.usersupport.model.DgutEvaluate;
import com.facebank.usersupport.model.RestModel;
import com.facebank.usersupport.service.IShopService;
import com.facebank.usersupport.util.SessionUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

/**
 * @Auther: yaozun
 * @Date: 2018/4/8 0008 08:59
 * @Description:
 */
@RestController
public class ShopController {
    @Autowired
    private IShopService shopService;

    /**
     *加入购物车
     */
    @RequestMapping(value = "/shop/add_cart",produces = MediaType.APPLICATION_JSON_VALUE)
    public RestModel addCart(Integer actId, Integer adultNum, Integer childNum, HttpSession session){
        return shopService.addCart(actId,adultNum,childNum,session);
    }
    /**
     *下单
     */
    @RequestMapping(value = "/shop/add_order",produces = MediaType.APPLICATION_JSON_VALUE)
    public RestModel addOrder(Integer actId, Integer adultNum, Integer childNum, HttpSession session){
        return shopService.addOrder(actId,adultNum,childNum,session);
    }
    /**
     *支付
     */
    @RequestMapping(value = "/shop/pay_order",produces = MediaType.APPLICATION_JSON_VALUE)
    public RestModel payOrder(Long orderNo, HttpSession session){
        return shopService.payOder(orderNo,session);
    }
    /**
     * 查看个人购物车
     */
    @RequestMapping(value = "/shop/show_cart",produces = MediaType.APPLICATION_JSON_VALUE)
    public RestModel showCart( HttpSession session){
        return shopService.showCart(session);
    }
    /**
     * 查看个人订单
     */
    @RequestMapping(value = "/shop/show_order",produces = MediaType.APPLICATION_JSON_VALUE)
    public RestModel showOrder( HttpSession session){
        return shopService.showOrder(session);
    }
    /**
     * 結算
     */
    @RequestMapping(value = "/shop/balance",produces = MediaType.APPLICATION_JSON_VALUE)
    public RestModel balance(@RequestParam(value = "id[]") Long[] id, HttpSession session){
        return shopService.balance(id);
    }
    /**
     * 显示待评价列表
     */
    @RequestMapping(value = "/shop/evaluate_showList",produces = MediaType.APPLICATION_JSON_VALUE)
    public RestModel evaluateShowList(HttpSession session){
        return shopService.evashowList(session);
    }
    /**
     * 添加活动评价
     */
    @RequestMapping(value = "/shop/evaluate_add",produces = MediaType.APPLICATION_JSON_VALUE)
    public RestModel evaluateAdd(DgutEvaluate dgutEvaluate, HttpSession session){
        Long assId = Long.valueOf(SessionUtil.getAssociatorId(session));
        dgutEvaluate.setAssociatorId(assId);
        return shopService.addEvaluate(dgutEvaluate);
    }
    /**
     * 查看订单详情
     */

    @RequestMapping(value = "/shop/order_detail",produces = MediaType.APPLICATION_JSON_VALUE)
    public RestModel orderDetail(Long orderNo){
        return shopService.showOrderDetail(orderNo);
    }

}
